package test00.tx07;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;

public class MainTest {
    public static void main(String[] args) {
        List<Student> list = new ArrayList<Student>();

        list.add(new Student("李三", 20));
        list.add(new Student("李四", 18));
        list.add(new Student("李五", 21));
        list.add(new Student("赵五1", 17));
        list.add(new Student("赵五2", 23));
        list.add(new Student("赵六", 19));

        // 第二：把数据源转换为 Stream 对象 - 流对象
        Stream<Student> stream = list.stream();
        stream.filter(student -> student.getName().startsWith("李"))
                .filter(student -> student.getAge() > 18)
                .sorted((student,student01) -> student01.age - student.age)
                .map(Student::getName)
                .limit(2)
                .forEach(System.out::println);
    }
}
